package swing.bubble;

import javax.swing.*;
import javax.swing.border.AbstractBorder;
import javax.swing.border.EmptyBorder;
import java.awt.*;

public class BorderTest {

    public static void main(String[] args) {
        Runnable r = () -> {
            JPanel gui = new JPanel(new GridLayout(2, 0, 5, 5));
            gui.setBorder(new EmptyBorder(10, 10, 10, 10));
            gui.setBackground(Color.GREEN);

            AbstractBorder borderLeft = new TextBubbleBorder(Color.BLACK, 2, 16, 16);
            AbstractBorder borderRight = new TextBubbleBorder(Color.BLACK, 2, 16, 16, false);

            JLabel l1 = new JLabel("Label 1");
            l1.setBorder(borderRight);
            gui.add(l1);

            JLabel l2 = new JLabel("Label 2");
            l2.setBorder(borderLeft);
            l2.setBackground(Color.YELLOW);
            l2.setOpaque(true);
            gui.add(l2);

            JPanel p1 = new JPanel();
            p1.add(new JLabel("Panel 1"));
            p1.setBorder(borderRight);
            p1.setOpaque(false);
            gui.add(p1);

            JPanel p2 = new JPanel();
            p2.add(new JLabel("Panel 2"));
            p2.setBorder(borderLeft);
            gui.add(p2);

            JOptionPane.showMessageDialog(null, gui);
        };
        // Swing GUIs should be created and updated on the EDT
        // http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html
        SwingUtilities.invokeLater(r);
    }

}

